import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { UserService } from "./user.service";
import { User } from '../domain/user';
import { AngularWaitBarrier } from 'blocking-proxy/built/lib/angular_wait_barrier';
@Injectable()
export class GuardService {
  user: User;
  constructor(private userService: UserService) { }

  



  canActivate() {    
    this.userService.getUserById(<number><any>localStorage.getItem('userId'))
    .then(user => this.user = user);
    if(this.user.power == true){
      return this.user.power;
    }else{
      alert("您还不是管理员，没有权限");
      return this.user.power;
    }
  }


}
